package cjyyp.utils;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author
 */


@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "请求返回类")
public class RespBean<T> {


    @ApiModelProperty(value = "返回状态值")
    private Integer status;


    @ApiModelProperty(value = "返回结果描述")
    private String msg;

    @ApiModelProperty(value = "返回数据")
    private T obj;

    /**
     * 成功时返回的结果对象
     * @param msg
     * @return
     */
    public static RespBean success(String msg) {
        return new RespBean(200, msg, null);
    }

    public static RespBean success(Object obj) {
        return new RespBean(200, "success", obj);
    }

    public static  RespBean success() {
        return new RespBean(200, "success", null);
    }

    /**
     * 成功时返回的结果对象
     * @param msg
     * @param obj
     * @return
     */
    public static RespBean success(String msg, Object obj) {
        return new RespBean(200, msg, obj);
    }

    /**
     * 失败时返回的结果对象
     * @param msg
     * @return
     */
    public static RespBean error(String msg) {
        return new RespBean(500, msg, null);
    }

    /**
     * 失败时返回的结果对象
     * @param msg
     * @param obj
     * @return
     */
    public static RespBean error(String msg, Object obj) {
        return new RespBean(500, msg, obj);
    }

    public static RespBean error(Object obj) {
        return new RespBean(500, "error", obj);
    }

    public static  RespBean error() {
        return new RespBean(500, "error", null);
    }
}